<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="app">
  <cpn></cpn>
</div>
<template id="cpn">
  <div>
    <ccpn></ccpn>
  </div>
</template>
<template id="ccpn">
  <div>
    <div>我是子组件</div>
    <button @click="btnClick">按钮</button>
  </div>
</template>
<script src="../vue.js"></script>
<script>
  const app = new Vue({
    el: '#app',
    data: {
      message: 'hello',
    },
    components: {
      cpn: {
        template: `#cpn`,
        methods: {},
        data(){
          return{name:'xqz'}
        },
        components: {
          ccpn: {
            template: `#ccpn`,
            methods: {
              btnClick() {
                // 访问父组件
                console.log(this.$parent.name);
              }
            }
          },
        }
      }
    }
  })
</script>
</body>
</html>
